
import requests
import bs4
import urllib
import sys
import importlib
importlib.reload(sys)
                            



with open("format.1649835003733.txt", 'r',encoding='utf-8') as file_to_read:
#   while True:
    lines = file_to_read.readlines()
#     print(lines)
for line in lines:
    print(line)
    linetmp=line
    if "- name:" in linetmp:
        url=u'https://h5.baike.qq.com/mobile/search.html?search='+linetmp[12:-1]+'&VNK=8621f000&adtag=ow'
        url.encode('utf-8')
        print(url)

#         req = urllib.request.Request(url)
#         response = urllib.request.urlopen(req)
#         content  = response.read().decode("utf-8")
#         print(content)
        req = urllib.request.urlopen(url)
 
        print(req.read().decode())
#         r = requests.get(url,headers=headers)
#         content = bs4.BeautifulSoup(r.content.decode("utf-8"), "lxml")
#         print(content)
        print(linetmp[12:])
        break